package team.nmsg.ge.system.bean;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;

import team.nmsg.ge.system.interf.ISysBean;

import com.alibaba.fastjson.JSONObject;

@Entity
public class SysOper implements ISysBean{
	
	public transient static int OTYPE_MENUGROUP = 1;
	public transient static int OTYPE_MENUS = 2;
	public transient static int OTYPE_MENU = 3;
	public transient static int OTYPE_OPER = 4;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer operId;
	//操作名
	private String operName;
	//操作描述
	private String operRemark;
	
	private Integer poId;
	
	private String icon;
	
	private String url;
	
	//保留字段
	private String standby1;
	private String standby2;
	//oper 类型 属于 title 或者 page  或者 操作
	private Integer otype = OTYPE_OPER;
	
    @ManyToMany(fetch=FetchType.LAZY , mappedBy="opers")
	private Set<SysRole> roles ;

	public Integer getOperId() {
		return operId;
	}

	public void setOperId(Integer operId) {
		this.operId = operId;
	}

	public String getOperName() {
		return operName;
	}

	public void setOperName(String operName) {
		this.operName = operName;
	}

	public String getOperRemark() {
		return operRemark;
	}

	public void setOperRemark(String operRemark) {
		this.operRemark = operRemark;
	}

	public Integer getPoId() {
		return poId;
	}

	public void setPoId(Integer poId) {
		this.poId = poId;
	}

	public String getStandby1() {
		return standby1;
	}

	public void setStandby1(String standby1) {
		this.standby1 = standby1;
	}

	public String getStandby2() {
		return standby2;
	}

	public void setStandby2(String standby2) {
		this.standby2 = standby2;
	}

	public Integer getOtype() {
		return otype;
	}

	public void setOtype(Integer otype) {
		this.otype = otype;
	}

	public Set<SysRole> getRoles() {
		return roles;
	}

	public void setRoles(Set<SysRole> roles) {
		this.roles = roles;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}
	
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Override
	public JSONObject toJson() {
		JSONObject obj = new JSONObject();
		obj.put("operId",operId);
		obj.put("operName",operName);
		obj.put("sysPoId",poId);
		obj.put("operRemark",operRemark);
		obj.put("url",url);
		obj.put("icon",icon);
		obj.put("standby1",standby1);
		obj.put("standby2",standby2);
		obj.put("otype",otype);
		
//		obj.put("id",operId);
//		obj.put("text",operName);
//		if(nmsPoId==-1)
//			obj.put("parent", "#");
//		else
//			obj.put("parent", nmsPoId);
		return obj;
		

	}
	
    
}
